class Solution(object):
    def toHex(self, num):
        """
        :type num: int
        :rtype: str
        """
        d = {10: 'a', 11: 'b', 12: 'c', 13: 'd', 14: 'e', 15: 'f'}
        if num < 0:
            num += 2 ** 32
        s = ''
        while num // 16 > 0:
            yushu = num % 16
            num = num // 16
            if yushu < 10:
                s += str(yushu)
            else:
                s += d[yushu]
        if num < 10:
            s += str(num)
        else:
            s += d[num]
        return s[::-1]


data = Solution()
num = -1
print(data.toHex(num))